package com.ruoyi.basicData.ruleSetting.service.impl;

import java.util.List;

import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.basicData.ruleSetting.mapper.VehicleIdRulesMapper;
import com.ruoyi.basicData.ruleSetting.domain.VehicleIdRules;
import com.ruoyi.basicData.ruleSetting.service.IVehicleIdRulesService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 车辆ID规则Service业务层处理
 * 
 * @author YiYuan
 * @date 2024-01-23
 */
@Service
@RequiredArgsConstructor
public class VehicleIdRulesServiceImpl implements IVehicleIdRulesService 
{
    private final VehicleIdRulesMapper vehicleIdRulesMapper;
    private final RedisCache redisCache;

    /**
     * 查询车辆ID规则
     * 
     * @param id 车辆ID规则主键
     * @return 车辆ID规则
     */
    @Override
    public VehicleIdRules selectVehicleIdRulesById(Long id)
    {
        return vehicleIdRulesMapper.selectVehicleIdRulesById(id);
    }

    /**
     * 查询车辆ID规则列表
     * 
     * @param vehicleIdRules 车辆ID规则
     * @return 车辆ID规则
     */
    @Override
    public List<VehicleIdRules> selectVehicleIdRulesList(VehicleIdRules vehicleIdRules)
    {
        return vehicleIdRulesMapper.selectVehicleIdRulesList(vehicleIdRules);
    }

    /**
     * 新增车辆ID规则
     * 
     * @param vehicleIdRules 车辆ID规则
     * @return 结果
     */
    @Override
    public int insertVehicleIdRules(VehicleIdRules vehicleIdRules)
    {
        return vehicleIdRulesMapper.insertVehicleIdRules(vehicleIdRules);
    }

    /**
     * 修改车辆ID规则
     * 
     * @param vehicleIdRules 车辆ID规则
     * @return 结果
     */
    @Override
    public int updateVehicleIdRules(VehicleIdRules vehicleIdRules)
    {
        redisCache.deleteObject(CacheConstants.RULE_BIKE_ID_KEY);
        redisCache.deleteObject("vehicle_id");
        return vehicleIdRulesMapper.updateVehicleIdRules(vehicleIdRules);
    }

    /**
     * 批量删除车辆ID规则
     * 
     * @param ids 需要删除的车辆ID规则主键
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteVehicleIdRulesByIds(Long[] ids)
    {
        return vehicleIdRulesMapper.deleteVehicleIdRulesByIds(ids);
    }

    /**
     * 删除车辆ID规则信息
     * 
     * @param id 车辆ID规则主键
     * @return 结果
     */
    @Override
    public int deleteVehicleIdRulesById(Long id)
    {
        return vehicleIdRulesMapper.deleteVehicleIdRulesById(id);
    }
}
